package com.spica.platform.base.feign.fallback;

import com.spica.platform.base.feign.UserFeignClient;
import com.spica.platform.base.model.LoginAppUser;
import com.spica.platform.base.model.ResponseEntity;
import com.spica.platform.base.model.SysUser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

/**
 * UserFeignClient降级工场
 */
@Slf4j
public class UserFeignClientFallbackFactory implements FallbackFactory<UserFeignClient> {
    @Override
    public UserFeignClient create(Throwable throwable) {
        return new UserFeignClient() {
            @Override
            public ResponseEntity<SysUser> findSysUserByUsername(String username) {
                log.error("通过用户名查询用户异常:{}", username, throwable);
                return null;
            }

            @Override
            public ResponseEntity<LoginAppUser> findLoginAppUserByUsername(String username) {
                log.error("通过用户名查询用户异常:{}", username, throwable);
                return null;
            }

            @Override
            public ResponseEntity<LoginAppUser> findLoginAppUserByMobile(String mobile) {
                log.error("通过手机号查询用户异常:{}", mobile, throwable);
                return null;
            }

            @Override
            public ResponseEntity<LoginAppUser> findLoginAppUserByUserId(String userId) {
                log.error("通过userId查询用户异常:{}", userId, throwable);
                return null;
            }
            
            @Override
            public ResponseEntity<LoginAppUser> findLoginAppUserByOpenId(String openId) {
                log.error("通过openId查询用户异常:{}", openId, throwable);
                return null;
            }
        };
    }
}
